home *** CD-ROM | disk | FTP | other *** search
- /* MainWindow.c */
- /* Created 01/01/95 12:01 PM by AppMaker */
-
- #include <Types.h>
- #include <Quickdraw.h>
- #include <Controls.h>
- #include <Dialogs.h>
- #include <Events.h>
- #include <Lists.h>
- #include <Menus.h>
- #include <Resources.h>
- #include <TextEdit.h>
- #include <ToolUtils.h>
- #include "ResourceDefs.h"
- #include "Globals.h"
- #include "Miscellany.h"
- #include "Scrolling.h"
- #include "WindowAids.h"
- #include "AMReminderData.h"
- #include "Add.h"
- #include "MainWindow.h"
-
- #define LogoPicture 1
- #define YearLabel 2
- #define RemindersLabelLabel 3
- #define RemindersList 4
- #define AddButton 5
- #define EditButton 6
- #define DeleteButton 7
-
- static void BuildRemindersList (void);
- static void DoAddButton (void);
- static void DoEditButton (void);
- static void DoDeleteButton (void);
-
- /*----------*/
- static void BuildRemindersList ()
- {
- Rect bounds;
-
- SetWFont (RemindersList);
- GetWRect (RemindersList, &bounds);
- cur->RemindersHandle = NewV1List (bounds, qd.thePort);
- AddToList ("\pOne", cur->RemindersHandle);
- AddToList ("\pTwo", cur->RemindersHandle);
- AddToList ("\pThree", cur->RemindersHandle);
- AddToList ("\pInfinity", cur->RemindersHandle);
- LDoDraw (true, cur->RemindersHandle);
-
- } /*BuildRemindersList*/
-
- /*----------*/
- static void DoAddButton ()
- {
- AddRec AddInfo;
- register AddRecPtr info;
-
- info = &AddInfo;
- /*initialize Add info*/
- info->LogoData = nil;
- info->DateText [0] = 0;
- info->TimeText [0] = 0;
- info->AmPmChoice = 1;
- info->MessageText [0] = 0;
- info->DisplayIconChecked = false;
- info->DisplayAlertChecked = false;
- info->PlaySoundChecked = false;
- info->SoundChoice = 1;
-
- if (GetAdd (&AddInfo)) {
- /*use Add info*/
- }
- } /*DoAddButton*/
-
- /*----------*/
- static void DoEditButton ()
- {
- AddRec AddInfo;
- register AddRecPtr info;
-
- info = &AddInfo;
- /*initialize Add info*/
- info->LogoData = nil;
- info->DateText [0] = 0;
- info->TimeText [0] = 0;
- info->AmPmChoice = 1;
- info->MessageText [0] = 0;
- info->DisplayIconChecked = false;
- info->DisplayAlertChecked = false;
- info->PlaySoundChecked = false;
- info->SoundChoice = 1;
-
- if (GetAdd (&AddInfo)) {
- /*use Add info*/
- }
- } /*DoEditButton*/
-
- /*----------*/
- static void DoDeleteButton ()
- {
- } /*DoDeleteButton*/
-
- /*----------*/
- void OpenMainWindow (Str255 fName,
- short vRefNum,
- short fRefNum)
- {
- WindowPtr newWindow;
- Rect bounds;
-
- newWindow = GetWindow (WIND_MainWindow);
- if (fName [0] != 0) {
- SetWTitle (newWindow, fName);
- }
- SetPort (newWindow);
- SetNewInfo (newWindow);
- cur->vScroll = nil;
- cur->hScroll = nil;
- cur->fileNum = fRefNum;
- cur->volNum = vRefNum;
- cur->dirty = false;
- cur->filename = NewString (fName);
- cur->windowKind = WMainWindow;
- ((WindowPeek) curWindow)->windowKind = userKind + WMainWindow;
- cur->witlHandle = GetResource ('Witl', WIND_MainWindow);
- cur->wictHandle = GetResource ('Wict', WIND_MainWindow);
-
- BuildRemindersList ();
- cur->AddHandle = GetNewControl (CNTL_Add, newWindow);
- cur->EditHandle = GetNewControl (CNTL_Edit, newWindow);
- cur->DeleteHandle = GetNewControl (CNTL_Delete, newWindow);
- cur->text = nil;
-
- ShowWindow (newWindow);
-
- } /*OpenMainWindow*/
-
- /*----------*/
- void CloseMainWindow (void)
- {
- LDispose (cur->RemindersHandle);
-
- DisposHandle ((Handle) cur->filename);
- DiscardInfo (curWindow);
- } /*CloseMainWindow*/
-
- /*----------*/
- void ControlMainWindow (ControlHandle whichControl,
- short whichPart,
- Point where)
- {
- Rect bounds;
-
- if ((whichControl == (**(cur->RemindersHandle)).vScroll)
- || (whichControl == (**(cur->RemindersHandle)).hScroll)) {
- if (LClick (where, 0, cur->RemindersHandle)) {
- /*double click in scroll bar*/
- }
- }
- if (whichControl == cur->AddHandle) {
- if (TrackButton (cur->AddHandle, where)) {
- DoAddButton ();
- }
- }
- if (whichControl == cur->EditHandle) {
- if (TrackButton (cur->EditHandle, where)) {
- DoEditButton ();
- }
- }
- if (whichControl == cur->DeleteHandle) {
- if (TrackButton (cur->DeleteHandle, where)) {
- DoDeleteButton ();
- }
- }
-
- } /*ControlMainWindow*/
-
- /*----------*/
- void MouseInMainWindow (Point where,
- short modifiers)
- {
- Rect bounds;
-
- if (PtInRect (where, &(**(cur->RemindersHandle)).rView)) {
- if (LClick (where, modifiers, cur->RemindersHandle)) {
- /*double click*/
- }
- if (GetListChoice (&cur->RemindersChoice, cur->RemindersHandle)) {
- /* something is selected */
- }
- }
-
- } /*MouseInMainWindow*/
-
- /*----------*/
- void TypeInMainWindow (char ch)
- {
- if (cur->text == nil) {
- SysBeep (1);
- } else {
- TEKey (ch, cur->text);
- cur->dirty = true;
- }
- } /*TypeInMainWindow*/
-
- /*----------*/
- void UpdateMainWindow (void)
- {
- Rect bounds;
-
- GetWRect (LogoPicture, &bounds);
- DrawPictureID (PICT_Logo, bounds);
- SetWFont (YearLabel);
- GetWRect (YearLabel, &bounds);
- TextIDBox (TEXT_Year, bounds);
- SetWFont (RemindersLabelLabel);
- GetWRect (RemindersLabelLabel, &bounds);
- TextIDBox (TEXT_RemindersLabel, bounds);
- SetWFont (RemindersList);
- LUpdate (qd.thePort->visRgn, cur->RemindersHandle);
- bounds = (**(cur->RemindersHandle)).rView;
- InsetRect (&bounds, -1, -1);
- FrameRect (&bounds);
- SetWFont (AddButton);
- Draw1Control (cur->AddHandle);
- SetWFont (EditButton);
- Draw1Control (cur->EditHandle);
- SetWFont (DeleteButton);
- Draw1Control (cur->DeleteHandle);
- } /*UpdateMainWindow*/
-
- /*----------*/
- void ActivateMainWindow (Boolean activate)
- {
- LActivate (activate, cur->RemindersHandle);
-
- } /*ActivateMainWindow*/
-
- /*----------*/
- void ResizeMainWindow (void)
- {
- /* application-specific code to resize items in window */
- } /*ResizeMainWindow*/
-
- /*----------*/
- pascal void ScrollMainWindow (short newValue,
- short oldValue)
- {
- /* application-specific code to scroll window */
- } /*ScrollMainWindow*/
-
- /* MainWindow */
-